package com.amar.dtadmin.apidoc.constant;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author xiaoshiqiang
 * @since 2025/2/11
 */
@AllArgsConstructor
@Getter
public enum TypeEnum {
    VARCHAR("VARCHAR(50)"),
    TEXT("TEXT"),
    MEDIUMTEXT("MEDIUMTEXT"),
    LONGTEXT("LONGTEXT"),
    NUMBER("NUMBER(20)"),
    DECIMAL("DECIMAL(18,2)"),
    ARRAY("ARRAY"),
    JSONARRAY("JSONARRAY"),
    JSONOBJECT("JSONOBJECT"),
    BOOLEAN("BOOLEAN"),
    OTHER("OTHER");

    private final String type;

    public static TypeEnum getEnumByType(String typeStr) {
        if (StrUtil.isNotEmpty(typeStr)) {
            for (TypeEnum type : TypeEnum.values()) {
                if (type.type.equals(typeStr)) {
                    return type;
                }
            }
        }
        return OTHER;
    }
}
